
//动态的创建一个table
function createShowingTable(data, page, total, total_page, current) {

    var per_page = 10;
    console.log('total:'+total+','+per_page+',current:'+current)
    data = data.data;
    var tableStr = "<table id='fixedTable' class='table table-striped jambo_table table-hover' data-toggle='table'>";
    tableStr = tableStr
        + `<thead>
                <tr>
                    <th><span>部门编号</span></th>
                    <th><span>部门名称</span></th>
                    <th><span>备注</span></th>
                    <th><span>添加日期</span></th>
                    <th><span>操作</span></th>
                </tr>
            </thead>`;
    var len = data.length;

    for ( var i = 0; i < len; i++) {
        tableStr = tableStr +
            '<tbody>'+
            '<tr>'+
            '<td>'+data[i].de_id+'</td>'+
            '<td>'+data[i].dept_name+'</td>'+
            '<td>'+data[i].description+'</td>'+
            '<td>'+data[i].create_time_d+'</td>'+
            '<td>'+
            '<a href="#" class="table-link" onclick=edit("'+data[i].de_id+'") title="修改">'+
            '<span class="fa-stack">'+
            '<i class="fa fa-square fa-stack-2x"></i>'+
            '<i class="fa fa-pencil fa-stack-1x fa-inverse"></i>'+
            '</span>'+
            '</a>'+
            '<a href="#" class="table-link danger class-del" onclick=del("'+data[i].de_id+'") title="删除">'+
            '<span class="fa-stack">'+
            '<i class="fa fa-square fa-stack-2x"></i>'+
            '<i class="fa fa-trash-o fa-stack-1x fa-inverse"></i>'+
            '</span>'+
            '</a>'+

            '</td>'+
            '</tr>'+

            '</tbody>';
    }
    tableStr = tableStr + "</table>";
    var pageStr = getPageBar(total, current, total_page);
    tableStr = tableStr + '<div style="text-align: center;font-size: 14px;">'+page+'</div>';
    //添加到div中
    $("#fixed").html(tableStr);
}
//获取分页条
function getPageBar(total, current, total_page){
    var pageStr = '';
    if(current > total_page){
        current = total_page;
    }
    if(current < 1){
        current = 1;
    }
    pageStr = "<span>共 "+total+" 条 </span><span>"+current+"/"+total_page+"</span>";
    //如果是第一页
    if(current==1){
        pageStr += "<span> 首页 </span><span> 上一页 </span>";
    }else{
        pageStr += "<span><a href='/orders/dept/index.html?/orders/dept/index_html=&depts=&page=1' rel='1'> 首页 </a></span>" +
            "<span><a href='/orders/dept/index.html?/orders/dept/index_html=&depts=&page="+(parseInt(current)-1)+"' rel='"+(current-1)+"'> 上一页 </a></span>";
    }

    //如果是最后页
    if(current>=total_page){
        pageStr += "<span> 下一页 </span><span> 尾页 </span>";
    }else{
        pageStr += "<span><a href='/orders/dept/jsonlist.html?/orders/dept/jsonlist_html=&depts=&page="+(parseInt(current)+1)+"' rel='"+(parseInt(current)+1)+"'> 下一页 </a></span>" +
            "<span><a href='/orders/dept/index.html?/orders/dept/index_html=&depts=&page="+total_page+"' rel='"+total_page+"'> 尾页 </a></span>";
    }
    return pageStr;
}